package com.ruoyi.web.controller.example;

import com.ruoyi.banner.domain.Banner;
import com.ruoyi.banner.service.BannerService;
import com.ruoyi.common.annotation.Anonymous;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.student.domain.Student;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.v3.oas.annotations.parameters.RequestBody;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Anonymous
@RestController
@Api(tags = "轮播图管理")
public class BannerController {

    @Autowired
    BannerService service;


    @ApiOperation("获取所有轮播图列表")
    @GetMapping("/GetBannerList")
    public AjaxResult GetBannerList(){
        return AjaxResult.success(service.getBannerList());
    }

    @ApiOperation("新增轮播图")
    @PostMapping("/AddBanner")
    public AjaxResult AddBanner(@RequestBody Banner banner) {
        int result = service.addBanner(banner);
        return AjaxResult.success(result);
    }

    @ApiOperation("修改轮播图信息")
    @PutMapping("/ModifyBanner")
    public AjaxResult ModifyBanner(@RequestBody Banner banner){
        service.updateBanner(banner);
        return AjaxResult.success();
    }

    @ApiOperation("删除轮播图信息")
    @DeleteMapping("/DeleteBanner")
    public AjaxResult DeleteSBanner(int id){
        service.deleteBanner(id);
        return AjaxResult.success();
    }
}
